home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
bluebook.zip
/
FLOATPT.DOC
< prev
next >
Wrap
Text File
|
1986-05-14
|
19KB
|
434 lines
FLOATPT.DOC -- Floating Point Conversion Procedures
===================================================
From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
by Christopher L. Morgan
Copyright (C) 1984 by The Waite Group, Inc.
Purpose: These procedures perform input, conversion, and output on
floating point numbers.
Contents:
---------
BIN802DEC -- Convert from 80-bit binary to decimal digits
DECDOUBLE -- Double a temporary decimal floating point number
DECHALF -- Halve a temporary decimal floating point number
DECNORM -- Normalize temporary decimal floating point
DFP2SFP -- Convert from double to single precision floating point
FIX -- Convert from floating point to 16-bit integer
FLOAT -- Convert from 16-bit integer to floating point
FPIN -- Convert from external to internal floating point
FPINDIGIT -- Convert from decimal digit to temporary floating point
FPOUT -- Convert from internal to external floating point
FPTDIV -- Divide temporary floating point by 10
FPTMUL -- Multiply temporary floating point by 10
FPTNORM -- Normalize temporary floating point
SFP2DFP -- Convert from single to double precision floating point
SFP2TFP -- Convert from single precision to temporary floating point
SGNDEC16IN -- Convert from ASCII signed decimal to binary
TDECSHOW -- Display floating point
TFP2SFP -- Convert from temporary floating point to single precision
_____________________________________________________________________________
Overview
__________________________ FLOATING POINT ROUTINES __________________________
-----------------------------------------------------------------------------
Conversion from 80-bit binary to decimal digits
BIN802DEC
Function: This routine converts an 80-bit binary integer to a decimal string.
Input: Upon entry, SI points to an 80-bit binary integer to be used as input
and DI points to a 25-digit decimal string to be used as output.
Output: Upon exit, a 25-digit decimal string is where DI pointed upon entry.
DI still points there upon exit.
Registers used: AX, BX, CX, DX, and SI are modified; DI points to output.
Segments referenced: The data segment contains storage for the 80-bit binary
number (10 bytes) and the 25-digit decimal number (25 bytes).
Note: This is a near procedure needed by FPOUT.
-----------------------------------------------------------------------------
Double a temporary decimal floating point number
DECDOUBLE
Function: This routine multiplies a temporary decimal floating point
number by two.
Input: Upon entry, DS:DI points to a temporary decimal floating point number.
Output: Upon exit, the number has been doubled.
Registers used: AX,CX, & DX are modified.
Segments referenced: The data segment contains storage for the temporary
decimal floating point number.
Note: This is a near procedure needed by FPOUT.
-----------------------------------------------------------------------------
Half a temporary decimal floating point number
DECHALF
Function: This routine divides a temporary decimal floating number by two.
Input: Upon entry, DI points to a temporary decimal floating point number.
Output: Upon exit, the number has been divided by two. The result is not
normalized.
Registers used: AX, CX, and DI are modified.
Segments referenced: The data segment contains a temporary decimal floating
point number.
Note: This is a near procedure needed by FPOUT.
-----------------------------------------------------------------------------
Normalize a temporary decimal floating point number
DECNORM
Function: This routine normalizes a temporary decimal floating number.
Input: Upon entry, DI points to a temporary decimal floating point number.
Output: Upon exit, the number is normalized.
Registers used: AX, CX, and DI are modified.
Segments referenced: The data segment contains a temporary decimal floating
point number.
Note: Equates are used to shorten address fields. This is a near procedure
needed by FPOUT.
-----------------------------------------------------------------------------
Convert from double to single precision floating point
DFP2SFP
Function: This routine converts an internal double precision binary floating
point number to an internal single precision floating point number.
Input: Upon entry, a double precision binary floating point number is in
DFPBUFF. The double precision floating point number has a 40-bit binary
mantissa, a sign bit, and an 8-bit exponent biased by 128.
Output: Upon exit, a single precision binary floating point number is in
SFPBUFF. The single precision floating point number has a 24-bit binary
mantissa, a sign bit, and an 8-bit exponent biased by 128.
Registers used: Unmodified; AX is saved and restored.
Segments referenced: The data segment contains storage for the variables,
SFPBUFF and DFPBUFF.
Note: Equates are used to shorten address fields.
-----------------------------------------------------------------------------
Convert from floating point to 16-bit integer
FIX
Function: This routine converts from internal single precision binary
floating point to internal 16-bit signed two's complement integer.
Input: Upon entry, a single precision binary floating point is in SFPBUFF.
The single precision floating point number has a 24-bit binary mantissa,
a sign bit, and an 8-bit exponent biased by 128.
Output: Upon exit, a 16-bit signed two's complement binary number is in DX.
Registers used: DX is used for output; CX,and AX are saved and then restored.
Segments referenced: The data segment contains storage for SFPBUFF.
Note: Equates are used to shorten address fields.
-----------------------------------------------------------------------------
Convert from 16-bit integer to floating point
FLOAT
Function: This routine converts an unsigned 16-bit binary number to a
single precision binary floating point number.
Input: Upon entry, DX contains an unsigned 16-bit binary number.
Output: Upon exit, SFPBUFF contains a single precision floating point
number. The single precision floating point number has a 24-bit binary
mantissa, a sign bit, and an 8-bit exponent biased by 128.
Registers used: Unmodified; DX is used for input; DX, CX, & AX are saved
and then restored.
Segments referenced: The data segment contains storage for the variable,
SFPBUFF and the message, INTERNAL.
Routines called: STDMSG_OUT,HEX16OUT,STD_SPACE (all for debugging).
Note: Equates are used to shorten address fields.
-----------------------------------------------------------------------------
Convert from external to internal floating point
FPIN
Function: This routine accepts an ASCII decimal floating point number from
a standard input device and converts it to internal binary floating point.
Input: The characters of the floating point number are received in ASCII
through a call to a standard input routine. The decimal floating point
number has an optional sign, followed by decimal digits of the mantissa
with one embedded decimal point. Following the mantissa is an optional
exponent starting with the letter, 'E', then an optional sign, then a
decimal number. It is possible to get erroneous results if the number is
too large or small to be stored as a single precision binary floating
point number.
Output: Upon exit a single precision binary floating point number is in
SFPBUFF. The single precision floating point number has a 24-bit binary
mantissa, a sign bit, and an 8-bit exponent biased by 128.
Registers used: Unmodified; DI, SI, DX, CX, & AX are saved and restored.
Segments referenced: The data segment contains the variables, FPTEMP1,
FPTEMP2, and SFPBUFF.
Routines called: STD_IN, FPINDIGIT, FPMUL, FPTDIV, and FPTNORM.